package pl.bmajsak.dzone.stories

import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.ie.InternetExplorerDriver
import org.openqa.selenium.support.PageFactory

import pl.bmajsak.dzone.pages.*

description "Search dzone.com for articles from Java exPress magazine."

before "Start WebDriver", {
	driver = new FirefoxDriver();
}

scenario "Searching for Java exPress magazine link on dzone.com", {
	
	given "user is on dzone.com main page", {
		mainPage = PageFactory.initElements(driver, DzoneMainPage.class)
	}
	
	when "he searches for 'java express'", {
		searchResultPage = mainPage.searchFor("\"java express\"")
	}
	
	then "link to the javaexpress.pl website should be present in the results list", {
		results = searchResultPage.getSearchResultTitles()
		results.shouldHave "Free Java exPress newsletter available"
	}
}

after "Close WebDriver", {
	driver.close();
}
